package com.liljhu30.microdianping.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author LilJHu
 * @create 2023/12/15
 * @desc 请求结果统一响应实体
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private Boolean success;
    private String errorMsg;
    private Object data;
    private Long total;

    public static Result ok(){
        return new Result(true, null, null, null);
    }

    public static Result ok(Object data){
        return new Result(true, null, data, null);
    }

    public static Result ok(List<?> data, Long total){
        return new Result(true, null, data, total);
    }
    public static Result fail(String errorMsg){
        return new Result(false, errorMsg, null, null);
    }
}
